package com.bbx.taxi.client.Fragment;

import butterknife.ButterKnife;

import com.bbx.taxi.client.R;
import com.bbx.taxi.client.Bean.Extra.BasefragmentMsg;
import com.example.myfragment.RevealLayout;

import android.support.v4.app.Fragment;
import android.os.Build;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.animation.Animation;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;

public abstract  class MyFragment extends Fragment {
	LinearLayout contentFragment;
	RevealLayout revealLayout;
    public int layoutid;
	public void setContentView(int layoutid) {
        this.layoutid=layoutid;
   }
    abstract public void onCreateView( Bundle savedInstanceState);
    abstract public void initView();
        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
            View rootView = inflater.inflate(R.layout.base_fragment, container, false);
            contentFragment=(LinearLayout)rootView.findViewById(R.id.content_fragment);
            onCreateView(savedInstanceState);
            contentFragment.addView(inflater.inflate(layoutid, container, false));
            ButterKnife.bind(this, rootView);
            final int x=getArguments().getInt(BasefragmentMsg.X);
            final int y=getArguments().getInt(BasefragmentMsg.Y);
             revealLayout=(RevealLayout)rootView.findViewById(R.id.reveal_layout);
             revealLayout.setContentShown(false);
              revealLayout.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
                @Override
                public void onGlobalLayout() {
                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                        revealLayout.getViewTreeObserver().removeOnGlobalLayoutListener(this);
                    } else {
                        //noinspection deprecation
                        revealLayout.getViewTreeObserver().removeGlobalOnLayoutListener(this);
                    }
                    revealLayout.postDelayed(new Runnable() {
                        @Override
                        public void run() {
                            revealLayout.show(x,y, 1000);
                        }
                    }, 50);
                }
            });
              initView();
            return rootView;
        }
    }
